#ifndef VIPDIALOG_H
#define VIPDIALOG_H

#include <QDialog>
#include "mainwindow.h"
#include "ui_vipdialog.h"
#include <QCloseEvent>
#include <QDateTime>
#include <QDebug>
#include <QSqlQuery>
#include <QList>
class MainWindow;
namespace Ui {
class VipDialog;
}
struct Record
{
    QString id;
    QString vip_name;
    QString vip_phone;
    QString vip_address;
    QString vip_grade;
    QString vip_integral;
    QString consumption;
    QString email;
    QString vip_remarks;
    Record(QSqlQuery *res) {
        id = res->value("id").toString();
        vip_name = res->value("vip_name").toString();
        vip_phone = res->value("vip_phone").toString();
        vip_address = res->value("vip_address").toString();
        vip_grade = res->value("vip_grade").toString();
        vip_integral = res->value("vip_integral").toString();
        consumption = res->value("consumption").toString();
        email = res->value("email").toString();
        vip_remarks = res->value("vip_remarks").toString();
    }
};


class VipDialog : public QDialog
{
    Q_OBJECT

public:
    explicit VipDialog(QWidget *parent = 0, MainWindow *_MainWindow = 0);
    void update_vipinfo(QList< Record > *_date = NULL);
    void init(QString field="");
    ~VipDialog();

protected:
    MainWindow *vMainWindow;
    Ui::VipDialog *ui;
signals:
     void vipClose(int x);

protected:
     void closeEvent(QCloseEvent *event);
private slots:
     void updata_time();
     void on_sales_pushButton_clicked();
     void on_purchase_pushButton_clicked();
     void on_exit_pushButton_clicked();
     void on_add_pushButton_clicked();
     void on_modify_pushButton_clicked();
     void on_cel_pushButton_clicked();
     void on_comboBox_sort_currentIndexChanged(int index);
     void on_pushButton_pre_clicked();
     void on_pushButton_next_clicked();
     void on_pushButton_goto_clicked();

     void on_pushButton_search_clicked();

private:
     int pageNow = 1;
     int pageTotal = -1;
     QList< Record >datePrevious;
     QList< Record >dateNow;
     QList< Record >dateForword;
};

#endif // VIPDIALOG_H
